<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>old user</title>
        <link href="../../script/seminar.css" rel="stylesheet">
        <script type="text/javascript">
            function fnSlctTopik() {
                var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                if (vIdxTema > 0) {
                    var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                    document.oldUserForm.hidIdTopik.value = vIdTema;
                    document.oldUserForm.method = 'POST';
                    document.oldUserForm.action = '../../logic/getDetilSeminarUser.php';
                    document.oldUserForm.submit();
                }
            }
            
            function fnDaftarSeminar() {
                var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                var vIdxUserGroup = document.getElementById("slctUserGroup").selectedIndex;
                var vIdxUserGroup = document.getElementById("slctUserGroup")[vIdxUserGroup].value;
                var vUserId = document.oldUserForm.hidIdUser.value;
                
                document.oldUserForm.hidIdTopik.value = vIdTema;
                document.oldUserForm.hidIdUserGroup.value = vIdxUserGroup;
                document.oldUserForm.hidIdUser.value = vUserId;
                //alert('vIdTema: ' + vIdTema + ', vUserId: ' + vUserId + ', vIdxUserGroup: ' + vIdxUserGroup);
                document.oldUserForm.method = 'POST';
                document.oldUserForm.action = '../../logic/daftarSeminar.php';
                document.oldUserForm.submit();
            }
            
            function fnLogOut() {
                document.oldUserForm.method = 'POST';
                document.oldUserForm.action = '../../logic/logout.php';
                document.oldUserForm.submit();
            }
            
            function fnUploadFile() {
                var vWinH = document.body.offsetHeight;
                var vWinW = document.body.offsetWidth;
                var vPopupH = 300;
                var vPopupW = 630;
                var vPosTop = (vWinH-vPopupH)/2;
                var vPosLeft = (vWinW-vPopupW)/2;
                var vURL = "uploadFile.php";
                var vName = "Upload File";
                var vSpecs = "width="+vPopupW+", height="+vPopupH+", top="+vPosTop+", left="+vPosLeft+", titlebar=no, menubar=no, status=no, resizable=no";
                window.open(vURL, vName, vSpecs);
            }
            
            function fnDownloadFile(vPaperId) {
                document.oldUserForm.hidPaperId.value = vPaperId;
                document.oldUserForm.method = 'POST';
                document.oldUserForm.action = '../../logic/FileDownload.php';
                document.oldUserForm.submit();
            }
            
            function fnHapusFile(vPaperId) {
                document.oldUserForm.hidPaperId.value = vPaperId;
                document.oldUserForm.method = 'POST';
                document.oldUserForm.action = '../../logic/FileHapus.php';
                document.oldUserForm.submit();
            }
            
            function fnRefresh() {
                location.reload();
            }
            
            function fnReviewer(vIdTema) {
                document.oldUserForm.hidIdTopik.value = vIdTema;
                document.oldUserForm.method = 'POST';
                document.oldUserForm.action = '../reviewer/review.php';
                document.oldUserForm.submit();
            }
        </script>
    </head>
    <body>
        <?php
        include("../../utility/connection.php");
        include("../../utility/general.php");
        include("../../model/mSeminar.php");
        include("../../model/mPaper.php");
        session_start();
        unset($_SESSION['userResult']);
        if (isset($_SESSION['arrResult'])) {
            $arrResult = $_SESSION['arrResult'];
            $_SESSION['userId'] = $arrResult[0];
        ?>
        <form name="oldUserForm" id="oldUserForm">
        <input type="hidden" name="hidIdTopik" id="hidIdTopik">
        <input type="hidden" name="hidIdUserGroup" id="hidIdUserGroup">
        <input type="hidden" name="hidIdUser" id="hidIdUser" value="<?php echo $arrResult[0] ?>">
        <input type="hidden" name="hidPaperId" id="hidPaperId">
        <table border="0" width="100%" height="100%">
            <tr valign="middle">
                <td align="center">
                    
                    <table width="50%" border="0" cellpadding="2" cellspacing="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td colspan="3">INFO USER</td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td colspan="3"><?php echo $arrResult[1] ?><br>
                                            <?php echo $arrResult[2] ?><br>
                                            <?php echo $arrResult[3] ?><br>
                                            <?php echo $arrResult[5] ?>, <?php echo $arrResult[6] ?><br>
                                            Telp:&nbsp;<?php echo $arrResult[7] ?><br>
                                            Email:&nbsp;<?php echo $arrResult[8] ?>
                                        </td>
                                    </tr>
                                    <tr class="tbl-header"><td colspan="3">INFO SEMINAR</td></tr>
                                    <tr class="tbl-body">
                                        <td>Topik</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="90%">
                                            <select name="slctTopik" id="slctTopik" onchange="fnSlctTopik()">
                                                <option>-- Pilih Seminar --
                                                <?php
                                                $topikId = '';
                                                if (isset($_SESSION['topikId'])) {
                                                    $topikId = $_SESSION['topikId'];
                                                }
                                                
                                                $resultSeminar = fnSelectAllSeminar();
                                                if ($resultSeminar) {
                                                    while($rowSeminar = mysql_fetch_row($resultSeminar)){
                                                ?>
                                                <option value="<?php echo $rowSeminar[0] ?>" <?php echo ($topikId == $rowSeminar[0])? 'SELECTED':'' ?>><?php echo $rowSeminar[1] ?>
                                                <?php
                                                    }
                                                }
                                                ?>
                                            </select>
                                        </td>
                                    </tr>
                                    <?php
                                    //include("../../utility/general.php");
                                    $seminarTopik = '';
                                    $seminarTgl = '';
                                    $seminarWaktu = '';
                                    $seminarLokasi = '';
                                    if (isset($_SESSION['seminarResult'])) {
                                        $seminarResult = $_SESSION['seminarResult'];
                                        $seminarTopik = $seminarResult[2];
                                        $tglOrig = $seminarResult[4];
                                        $digitTgl = substr($tglOrig,-2,2);
                                        $digitBulan = fnConvertMonth(substr($tglOrig,-5,2));
                                        $digitTahun = substr($tglOrig,0,4);
                                        $seminarWaktu = $seminarResult[5];
                                        $seminarLokasi = $seminarResult[3];
                                    ?>
                                    <tr class="tbl-body">
                                        <td>Uraian</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td>
                                            <textarea name="txtUraian" id="txtUraian" cols="75" rows="5"><?php echo $seminarTopik ?></textarea>
                                        </td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tanggal</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $digitTgl ?>&nbsp;<?php echo $digitBulan ?>&nbsp;<?php echo $digitTahun ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Waktu</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $seminarWaktu ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Lokasi</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $seminarLokasi ?></td>
                                    </tr>
                                    <?php
                                    }
                                    ?>
                                    
                                    <tr class="tbl-body">
                                        <td colspan="3">
                                            <?php
                                            if (isset($_SESSION['seminarUser'])) {
                                                // sudah terdaftar
                                                $seminarUser = $_SESSION['seminarUser'];
                                                $statusUser = $seminarUser[2];
                                                if ($statusUser == 2) {
                                                    // 2 = peserta
                                            ?>
                                                Anda telah terdaftar sebagai Peserta pada seminar ini
                                            <?php
                                                } else if ($statusUser == 3) {
                                                    // 3 = pembicara
                                            ?>
                                                Anda telah terdaftar sebagai Pembicara pada seminar ini
                                            <?php
                                                } else if ($statusUser == 4) {
                                                    // 4 = reviewer
                                                    $topikId = '';
                                                    if (isset($_SESSION['topikId'])) {
                                                        $topikId = $_SESSION['topikId'];
                                                    }
                                            ?>
                                                Anda telah terdaftar sebagai Pemeriksa pada seminar ini<br>
                                                Silakan masuk halaman khusus Pemeriksa di <a href="#" onclick="fnReviewer(<?php echo $topikId ?>)">sini</a><br>
                                            <?php
                                                }
                                            } else {
                                                if (isset($_SESSION['setDaftar'])) {
                                            ?>
                                                    Daftar&nbsp;sebagai&nbsp;
                                                    <select name="slctUserGroup" id="slctUserGroup">
                                                        <option value="2">Peserta
                                                        <option value="3">Pembicara
                                                    </select>&nbsp;
                                                    <button type="button" name="btDaftar" id="btDaftar" onclick="fnDaftarSeminar()">Daftar</button>
                                            <?php
                                                }
                                            }
                                            ?>
                                            <br>
                                            <?php
                                            if (isset($_SESSION['re-register'])) {
                                                include("logic/session_message.php"); 
                                            }
                                            ?>
                                        </td>
                                    </tr>
                                    
                                    <?php
                                    if (isset($_SESSION['seminarUser'])) {
                                        // sudah terdaftar
                                        $seminarUser = $_SESSION['seminarUser'];
                                        $statusUser = $seminarUser[2];
                                        if ($statusUser == 3) {
                                            // 2 = pembicara
                                    ?>
                                    <div id="pembicara">
                                        <tr class="tbl-body">
                                            <td>Dokumen</td>
                                            <td>&nbsp;:&nbsp;</td>
                                            <td>
                                                <table border="1" cellpadding="2" cellspacing="0" width="100%">
                                                    <tr class="tbl-header">
                                                        <td>Judul</td>
                                                        <td width="30%">Uraian</td>
                                                        <td>Nama&nbsp;File</td>
                                                        <td>Tgl&nbsp;Upload</td>
                                                        <td>Action</td>
                                                    </tr>
                                                    <?php
                                                    $UserId = $arrResult[0];
                                                    $resultPaper = fnGetAllPaper($UserId,$topikId);
                                                    if ($resultPaper) {
                                                        while($rowPaper = mysql_fetch_row($resultPaper)){
                                                            $tglUpload = $rowPaper[6];
                                                            $digitTglUpload = substr($tglUpload,-2,2);
                                                            $digitBulanUpload = fnConvertMonth(substr($tglUpload,-5,2));
                                                            $digitTahunUpload = substr($tglUpload,0,4);
                                                    ?>
                                                    <tr>
                                                        <td><?php echo $rowPaper[3] ?></td>
                                                        <td><?php echo $rowPaper[4] ?></td>
                                                        <td><?php echo $rowPaper[7] ?></td>
                                                        <td><?php echo $digitTglUpload ?>&nbsp;<?php echo $digitBulanUpload ?>&nbsp;<?php echo $digitTahunUpload ?></td>
                                                        <td align="center">
                                                            <button type="button" name="btDownloadFile" id="btDownloadFile" onclick="fnDownloadFile(<?php echo $rowPaper[0] ?>)">Download</button>
                                                            <button type="button" name="btHapusFile" id="btHapusFile" onclick="fnHapusFile(<?php echo $rowPaper[0] ?>)">Hapus</button>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                        }
                                                    }
                                                    ?>
                                                </table>
                                                <table border="1" cellpadding="2" cellspacing="0" width="100%">
                                                    <tr valign="middle">
                                                        <td align="center">
                                                            <button type="button" name="btUploadFile" id="btUploadFile" onclick="fnUploadFile()">Simpan Dokumen</button>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </div>
                                    <?php
                                        }
                                    }
                                    ?>
                                    
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                </td>
            </tr>
            
            <tr valign="middle">
                <td align="center">
                    <button type="button" name="btLogOut" id="btLogOut" onclick="fnLogOut()">LogOut</button>
                </td>
            </tr>
        </table>    
        </form>
        <?php
            if (isset($_SESSION['errmsg'])) {
                $errmsg = $_SESSION['errmsg'];
                echo $errmsg;
            }
        }
        ?>
    </body>
</html>
